home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / codecs / drawtextcodec / drawtextdecompress.c < prev   
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.1 KB  |  85 lines

  1. /*
  2.     File:        DrawTextDecompress.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Mark Krueger    
  7.  
  8.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/29/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #include    <QuickDraw.h>
  25. #include    "ImageCompression.h"
  26.  
  27. #include    "DrawTextCodec.h"
  28.  
  29. long Decompress(unsigned char *baseAddr,short rowBytes,short bwidth,short bheight,char *dataPtr);
  30. /*
  31.  
  32.     decompress bheight strips ( of bwidth blocks ) of data. Each block is represented 
  33.     by one character of the font from compressed data. Font is assumed to be the same
  34.     as that used in compression - ( font type style and size could be included in a header
  35.     before the actual compressed data if we wanted to be truly flexible, but for a half-hour
  36.      demo hack we dont wanna be) 
  37.     
  38.     destination must be 1-bit/pixel.
  39.     
  40.     should be called in 32-bit mode.
  41.     
  42. */
  43.  
  44. long
  45. Decompress(unsigned char *baseAddr,short rowBytes,short bwidth,short bheight,char *dataPtr)
  46. {
  47.  
  48.     char            *startDataPtr;
  49.     unsigned char     *rp,*bp;
  50.     short            i,x,y;
  51.     
  52.     startDataPtr = dataPtr;                /* remember where we started from */
  53.  
  54.     TextSize(FONT_SIZE);
  55.     TextFont(FONT_ID);
  56.     for ( y=0; y <  bheight; y++ ) {
  57.         rp = baseAddr;
  58.         for (x=0; x < bwidth; x++) {
  59.             bp = rp;
  60.             for ( i=0; i < FONT_HEIGHT; i++ ) {
  61.                 *bp = 0;
  62.                 bp += rowBytes;
  63.             }
  64.             MoveTo(x*FONT_WIDTH,BASE_LINE + y*FONT_HEIGHT);
  65.             DrawChar(*dataPtr++);
  66.             rp++;
  67.             if ( x < bwidth ) {
  68.                 bp = rp;
  69.                 for ( i=0; i < FONT_HEIGHT; i++ ) {
  70.                     *bp = 0;
  71.                     bp += rowBytes;
  72.                 }
  73.             }
  74.         }
  75.         baseAddr += rowBytes * FONT_HEIGHT;
  76.     } 
  77.     return (dataPtr - startDataPtr);    
  78.     
  79.  
  80. }
  81.  
  82.  
  83.  
  84.  
  85.